regex to dfa algorithm